package org.indt.scrum.dao.impl;

import java.util.List;

import org.hibernate.SessionFactory;
import org.indt.scrum.dao.ReactionDAO;
import org.indt.scrum.model.Reaction;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.hibernate3.HibernateTemplate;


public class ReactionDAOImpl implements ReactionDAO{

	private HibernateTemplate hibernateTemplate;

	@Autowired
	public ReactionDAOImpl(SessionFactory sessionFactory) {
		this.hibernateTemplate = new HibernateTemplate(sessionFactory);
	}
	
	@Override
	public void delete(Reaction entity) {
		this.hibernateTemplate.delete(entity);	
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<Reaction> listAll() {
		return this.hibernateTemplate.find("from Reaction");
	}
	
	@Override
	public Reaction load(Integer id) {
		return (Reaction) this.hibernateTemplate.load(Reaction.class, id);
	}
	
	@Override
	public void save(Reaction entity) {
		this.hibernateTemplate.save(entity);
		
	}
	
	@Override
	public void update(Reaction entity) {
		
		this.hibernateTemplate.update(entity);
	}

}
